#ifndef _SHELL_INNER_H_
#define _SHELL_INNER_H_

#ifdef __cplusplus
extern "C"
{
#endif

#include "system.h"
#include "os_sal.h"

#ifdef CONFIG_SHELL_ENABLE

enum input_stat
{
    WAIT_NORMAL,
    WAIT_SPEC_KEY,
    WAIT_FUNC_KEY,
};

typedef struct 
{
	enum input_stat stat;
	
	uint8_t echo_mode : 1;
	uint8_t prompt_mode : 1;
	
#ifdef CONFIG_SHELL_HISTORY_ENABLE
	uint16_t current_history;
    uint16_t history_count;

    char cmd_history[CONFIG_SHELL_HISTORY_LINES][CONFIG_SHELL_CMD_SIZE];
#endif	
	
	char line[CONFIG_SHELL_CMD_SIZE];
    uint8_t line_position;
    uint8_t line_curpos;
	
#ifdef CONFIG_SHELL_AUTH_ENABLE
    char password[CONFIG_SHELL_AUTH_PASSWORD_MAX];
#endif
} _shell_obj;





/* export var */
extern _shell_call_func_obj *_shell_call_func_begin, *_shell_call_func_end;
extern _sehll_call_var_obj *_shell_call_var_begin, *_shell_call_var_end;


/* export func */

#define shell_printf shell_port_printf  // printf

/* port */
void shell_port_init(void);
int shell_port_set_char(char ch);
int shell_port_get_char(void);
int shell_port_printf(const char *fmt, ...);
void shell_port_reboot(void);
void shell_port_chip_info(void);
uint32_t shell_port_get_freeheap(void);

/* msh */
void shell_msh_init(void);
uint8_t shell_msh_is_used(void);
void shell_msh_auto_complete(char *prefix);
int shell_msh_exec(char *cmd, uint32_t length);

/* cmd */
void shell_system_show_version(void);

#endif

#ifdef __cplusplus
}
#endif

#endif // _SHELL_INNER_H_
